// views/index/shop/translationcopy/ordermessage/index.js
var util = require('../../../../../../utils/util');
var area = require('../../../../../../utils/area');

var BASE_URL = getApp().globalData.BASE_URL
import Notify from '../../../../../../miniprogram_npm/@vant/weapp/notify/notify';
import Dialog from '../../../../../../miniprogram_npm/@vant/weapp/dialog/dialog';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: "",
    opendiqupop: false,
    ifswitch: false,
    columns: ['Aachen', 'Aalen', 'Augsburg', 'Baden', 'Bad Soden-Salmuenster', 'Bamberg', 'Bayreuth', 'Berlin', 'Bernburg', 'Biberach', 'Bielefeld', 'Birkenfeld', 'Bochum', 'Bonn', 'Braunschweig', 'Bremen', 'Chemnitz', 'Clausthal-Zellerfeld', 'Coburg', 'Cottbus', 'Darmstadt', 'Dessau', 'Dortmund', 'Dresden', 'Duesseldorf', 'Duisburg', 'Eichstätt', 'Erfurt', 'Erlangen', 'Essen', 'Frankfurt am Main', 'Frankfurt an der Oder', 'Freiberg', 'Freiburg', 'Friedrichshafen', 'Fulda', 'Furtwangen', 'Garching', 'Garmisch-Partenkirchen', 'Gatersleben', 'Geesthacht', 'Germersheim', 'Giessen', 'Goettingen', 'Greifswald', 'Hagen', 'Halle', 'Hamburg', 'Hannover', 'Heide', 'Heidelberg', 'Heidenheim', 'Hof', 'Hohenheim', 'Holzkirchen', 'Homburg', 'Ilmenau', 'Ingolstadt', 'Jena', 'Juelich', 'Kaiserslautern', 'Karlsruhe', 'Kassel', 'Kiel', 'Kleve', 'Koblenz', 'Koeln', 'Koethen', 'Konstanz', 'Landshut', 'Leipzig', 'Lindau', 'Ludwigshafen', 'Luebeck', 'Lueneburg', 'Magdeburg', 'Mainz', 'Mannheim', 'Marbach am Neckar', 'Marburg', 'Mildesheim', 'Mittweida', 'Monchengladbach', 'Muelheim an der Ruhr', 'Muenchen', 'Muenster', 'Neuss', 'Nordhausen', 'Nuernberg', 'oestrich-Winkel', 'Offenbach', 'Offenburg', 'Oldenburg', 'Osnabrueck', 'Paderborn', 'Passau', 'Pforzheim', 'Potsdam', 'Radolfzell am Bodensee', 'Ravensburg', 'Reutlingen', 'Rostock', 'Saarbruecken', 'Schmakalden', 'Schweinfurt', 'Schwerin', 'Senftenberg', 'Siegen', 'Stralsund', 'Stuttgart', 'Trier', 'Tuebingen', 'Ulm', 'Vallendar', 'Vechta', 'Villingen', 'Weimar', 'Weingarten in baden-Wuerttemberg', 'Weinheim', 'Wernigerode', 'Wessling', 'Wiesbaden', 'Wismar', 'Worms', 'Wuerzburg', 'Wuppertal', 'Zwickau', 'Other'],
    

    //第二页数据
    tel: "",
    wechat: "",
    contact_per: "",
    contact_tel: "",
    shifou: 0,
    shou_per: "",
    loca: "",
    yb: 0,
    city: 'Aachen',
    price: '',

//第一页数据
    name: '',
    x_spell: '',
    m_spell: '',
    sex: '',
    birth:'',
    born: '',
    marriage: '',
    country: '',
    passport: '',
    or_bank: '',
    bank_hu: '',
    bank_bic: '',
    bank_ren: '',


  },




  change_switch: function (e) {
    this.setData({
      ifswitch: e.detail
    })
  },

  opendiqupop: function () {
    this.setData({
      opendiqupop: true
    })
  },



  onClose: function () {
    this.setData({
      opendiqupop: false
    })
  },
  onConfirm: function (e) {
    this.setData({
      opendiqupop: false,
      city: e.detail.value
    })
  },






































  //立即办理
  placeorder: function () {
    var _this = this
    var userinfo = wx.getStorageSync("USER")
    if (_this.data.tel == "") {
      Notify('联系电话不能为空');
    }
    if (_this.data.wechat == "") {
      Notify('微信号码不能为空');
    }
    if (_this.data.contact_per == "") {
      Notify('联系人姓名不能为空');
    }
    if (_this.data.contact_tel == "") {
      Notify('联系人电话不能为空');
    }



    if (_this.data.contact_tel !== "" && _this.data.contact_per !== "" && _this.data.tel !== "" && _this.data.wechat !== "") {
      wx.request({
        url: `${BASE_URL}/baoxian/gonglidata`,
        method: "POST",
        data: {
          uid: userinfo.id,
          type: 'xiaochengxv',
          id: _this.data.id,
          tel: _this.data.tel,
          wechat: _this.data.wechat,
          contact_per: _this.data.contact_per,
          contact_tel: _this.data.contact_tel,
          shifou: _this.data.ifswitch ? 1 : 0,
          shou_per: _this.data.shou_per,
          loca: _this.data.loca,
          yb: _this.data.yb,
          city: _this.data.city,
          //第一页数据
          name: _this.data.name,
          x_spell: _this.data.x_spell,
          m_spell: _this.data.m_spell,
          sex: _this.data.sex,
          birth: _this.data.birth,
          born: _this.data.born,
          marriage: _this.data.marriage,
          country: _this.data.country,
          passport: _this.data.passport,
          or_bank: _this.data.or_bank,
          bank_hu: _this.data.bank_hu,
          bank_bic: _this.data.bank_bic,
          bank_ren: _this.data.bank_ren,
        },
        header: {
          'Content-Type': 'application/json' //GET方式是这个
        },
        success(res) {
          console.log(res)
          wx.navigateTo({
            url: `../third/index?id=${res.data.id}`
          })
        }
      })

    }
  },


  getdatalist: function () {
    var _this = this
    var userinfo = wx.getStorageSync("USER")
    wx.request({
      url: `${BASE_URL}/baoxian/gonglidata`, //仅为示例，并非真实的接口地址
      data: {
        id: _this.data.id,
        type: 'xiaochengxv',
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 默认值
      },
      method: "get",
      success(res) {
        console.log(res)
        if(res.data.list.info){
          res.data.list.info = JSON.parse(res.data.list.info)
        }
        if(res.data.list.xinxi){
          res.data.list.xinxi = JSON.parse(res.data.list.xinxi)
        }
        _this.setData({
          // tel: res.data.list.tel,
          // wechat: res.data.list.wechat,
          // contact_per: res.data.list.contact_per,
          // contact_tel: res.data.list.contact_tel,
          // shou_per: res.data.list.shou_per,
          // loca: res.data.list.loca,
          // yb: res.data.list.yb,
          // city: res.data.list.city,
          price: res.data.list.amount,
          name: res.data.list.name,
          x_spell: res.data.list.x_spell,
          m_spell: res.data.list.m_spell,
          sex: res.data.list.sex,
          birth: res.data.list.birth,
          born: res.data.list.born,
          marriage: res.data.list.marriage,
          country: res.data.list.country,
          passport: res.data.list.passport,
          or_bank: res.data.list.bank,
          bank_hu: res.data.list.info.bank_hu,
          bank_bic: res.data.list.info.bank_bic,
          bank_ren: res.data.list.info.bank_ren,
        })
      }
    })
  },















  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.getdatalist()

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var userinfo = wx.getStorageSync("USER")
    this.setData({
      email: userinfo.email
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  //手机号正则
  codeVerification: function (phone) {
    let phoneCodeVerification = /^[1][3,4,5,7,8][0-9]{9}$/;
    return phoneCodeVerification.test(phone);
  },
  //英文字母正则
  ifenglish: function (pinyin) {
    let ifenglish = /^[A-Za-z]+$/;
    return ifenglish.test(pinyin);
  },
  //汉字正则
  ifhanzi: function (pinyin) {
    let ifhanzi = /^[\u4e00-\u9fa5]+$/;
    return ifhanzi.test(pinyin);
  },
  //微信号正则
  ifwewhat: function (pinyin) {
    let ifwewhat = /^[0-9a-zA-Z]*$/g;
    return ifwewhat.test(pinyin);
  },
  //邮箱验证
  ifemail: function (email) {
    let ifemail = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    return ifemail.test(email);
  },







})